<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>


<script type="text/javascript" src="js/calendar/calendar.js">.</script>
<script type="text/javascript" src="js/calendar/calendar-en.js">.</script>
<script type="text/javascript" src="js/calendar/calendar-setup.js">.</script>
<script type="text/javascript" src="<c:url value='/js/includes/prototype.js'/>">.</script>
<script type="text/javascript"
        src="<c:url value='/js/scriptaculous/scriptaculous.js?load=builder,effects,controls'/>"></script>
<script type="text/javascript" src="<c:url value='/js/includes/modalbox.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/springxt.js'/>"></script>

<style type="text/css">
    @import url( "<c:url value='/css/modalbox.css'/>" );
</style>

<style type="text/css"> @import url( "<c:url value='/css/calendar/calendar-win2k-1.css'/>" );</style>
<table>
    <input type="hidden" value="<bean:write name="checkoutForm" property="hiddenDate"/>" id="selectedDate"/>
    <tr>
        <td>
            <div style="float: right; margin-left: 1em; margin-bottom: 1em;"
                 id="calendar-container"></div>
        </td>
    </tr>
    <logic:empty name="checkoutForm" property="isStarted">
        <tr>
            <td>
                <html:link action="/day" paramId="hiddenDate" paramName="checkoutForm"
                           paramProperty="hiddenDate" styleClass="transbutton"><bean:message key="menu.link.start.day"/></html:link>
            </td>
        </tr>
    </logic:empty>
    <logic:notEmpty name="checkoutForm" property="isStarted">
        <logic:equal value="true" name="checkoutForm" property="isStarted">
            <tr>
                <td>
                    <html:link action="/cash" paramId="hiddenDate" paramName="checkoutForm"
                               paramProperty="hiddenDate" styleClass="transbutton"><bean:message
                            key="menu.link.cash.in.out"/>
                    </html:link>
                </td>
            </tr>
            <tr>
                <td>
                    <html:link action="/customer" paramId="hiddenDate" paramName="checkoutForm"
                               paramProperty="hiddenDate"
                               onclick="Modalbox.show(this.href, {title: this.firstChild.nodeValue, witdh: 600}); return false;"
                               styleClass="transbutton"><bean:message
                            key="menu.link.add.transaction"/></html:link>
                </td>
            </tr>
            <tr>
                <td>
                    <html:link action="/day" paramId="hiddenDate" paramName="checkoutForm"
                               paramProperty="hiddenDate" styleClass="transbutton"><bean:message
                            key="menu.link.end.day"/></html:link>
                </td>
            </tr>
        </logic:equal>
    </logic:notEmpty>
</table>

<script type="text/javascript">
    function dateChanged(calendar) {
        $("hiddenDate").value = calendar.date.getTime();
        document.forms["mainCheckoutForm"].submit();
    }

    var time = $F("selectedDate");
    var selectedDate = new Date();
    selectedDate.setTime(time);
    Calendar.setup(
    {
        flat         : "calendar-container", // ID of the parent element
        onUpdate     : dateChanged,
        date         : selectedDate
    }
            );
</script>
    